package cn.gz.demo.ui.pic;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.databinding.DataBindingUtil;

import cn.gz.demo.R;
import cn.gz.demo.databinding.PicMainBinding;
import cn.gz.demo.ui.base.BaseActivity;

/**
 * @author Liuyz
 * @date 2020/10/10 17:50
 */
public class PicMainActivity extends BaseActivity {
    private PicMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_pic_main);

        binding.icon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(PicMainActivity.this, PicDetailsActivity.class);
                int[] location = new int[2];
                binding.icon.getLocationOnScreen(location);
                intent.putExtra("locationX", location[0]);//必须
                intent.putExtra("locationY", location[1]);//必须

                intent.putExtra("width", binding.icon.getWidth());//必须
                intent.putExtra("height", binding.icon.getHeight());//必须
                startActivity(intent);
                overridePendingTransition(0, 0);
            }
        });
    }
}
